import React from 'react';
import PlaylistAddCheckOutlined from '@material-ui/icons/PlaylistAddCheckOutlined';
import { NavView, get_mod, loc, NavListSub } from 'sui';
import { LatheView, ForgeView, CeraView, StellView, SealView, CageView } from './base/view';
import { get_access } from 'cache';

const model = (cfg) => {
    const fix = [
        {uid: "qa.cage", view: CageView, value: loc("l_528")},
        {uid: "qa.seal", view: SealView, value: loc("l_529")},
        {uid: "qa.stell", view: StellView, value: loc("l_712")},
        {uid: "qa.cera", view: CeraView, value: loc("l_713")},
        {uid: "qa.lathe", view: LatheView, value: loc("l_894")},
        {uid: "qa.forge", view: ForgeView, value: loc("l_893")},
    ];

    let ret = get_mod(cfg, fix, "qa");
    let acc = get_access();

    if (acc && ret) {
        ret = ret.filter(d => acc.has(d.uid));
    }

    return ret;
};

const Qa = ({ mod, sideopen, cfg }) => <NavView cfg={cfg} model={model(cfg)} mod={mod} sideopen={sideopen} name="qa"/>;

const NavQa = (props) => <NavListSub icon={<PlaylistAddCheckOutlined/>} sub={model(props.cfg)} {...props} scut={15}/>;

export {NavQa, Qa};
